<script type="application/ld+json" data-test-id="product-json-ld">
  <% first_or_default_variant = product.first_or_default_variant(current_currency) %>
  {
    "@context": "https://schema.org/",
    "@type": "Product",
    "name": <%= product.name.to_json.html_safe %>,
    "url": <%= spree.product_url(product, host: current_store.url_or_custom_domain).to_json.html_safe %>,
  <% if product.featured_image %>
    "image": [
      <%= spree_image_url(product.featured_image, variant: :large).to_json.html_safe %>
    ],
  <% end %>
  <% if product.description.present? %>
    "description": <%= strip_tags(product.description).to_json.html_safe %>,
  <% end %>
  <% if !product.has_variants? %>
    <% if first_or_default_variant.sku.present? %>"sku": <%= first_or_default_variant.sku.to_json.html_safe %>,<% end %>
  <% elsif selected_variant %>
    <% if selected_variant.sku.present? %>"sku": <%= selected_variant.sku.to_json.html_safe %>,<% end %>
  <% end %>
  <% if product.brand_name %>
    "brand": {
      "@type": "Brand",
      "name": <%= product.brand_name.to_json.html_safe %>
    },
  <% end %>
"offers": [
  <% if product.has_variants? %>
  <%= raw(product.variants.map do |variant|
  render partial: "spree/products/json_ld_variant", locals: { product: product, variant: variant }
  end.join(",\n")) %>
  <% else %>
  <%= render "spree/products/json_ld_variant", product: product, variant: first_or_default_variant %>
  <% end %>
  ]
  }
</script>
<script type="application/ld+json">
  <%= product_json_ld_breadcrumbs(product).to_json.html_safe %>
</script>
